<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise 函数</title>
</head>

<body>
    <script>
        function print(delay, message) {
            return new Promise(function (resolve, reject) {
                setTimeout(function () {
                    console.log(message);
                    resolve();
                }, delay);
            });
        }

        print(1000, "First").then(function () {
            return print(4000, "Second");
        }).then(function () {
            print(3000, "Third");
        });
    </script>
    <!-- 这种返回值为一个 Promise 对象的函数称作 Promise 函数，它常常用于开发基于异步操作的库。 -->
</body>

</html>